package bsc.war.ajax;

import bsc.ejb.entity.Pointer;
import bsc.war.delegate.DelegateBSC;
import bsc.war.factory.Factory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**
 *
 * @author Miguel Angel
 */
public class AddCalculateData extends AbstractController {

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {

        DelegateBSC delegate = (DelegateBSC) Factory.getBean("DelegateBSC");
        ModelAndView mav = new ModelAndView("calculateData");

        //Find the scorecard
        Long idPointer = Long.parseLong(request.getParameter("scoreCard"));
        Pointer pointer = (Pointer) delegate.findScoreCard(idPointer);

        request.setAttribute("scoreCard", pointer);

        /*
        response.setContentType("application/vnd.ms-excel"); //Tipo de fichero.
        response.setHeader("Content-Disposition", "attachment;filename=\"report.xls\"");
         */

        return mav;
    }
}
